<template>
	<view>
		<!-- 页首 -->
		<zw-header></zw-header>
		<view style="position: relative;width: 80%;margin: 0 auto;">
			<image class="banner" src="/static/image/user/bg.png"></image>
		</view>


		<!-- 左侧导航栏 -->
		<menu-wrapper active-index="2-1" style="background-color: #fff;padding: 0;">
			<view class="card-header">
				<view class="left">
					<fui-avatar background="#fff" width="180" :src="loginUser.avator"></fui-avatar>
					<view class="user-info">
						<view class="user-name elip"
							style="display: flex;justify-content: space-between;align-items: center;">{{loginUser.name}}
							<view class="bigEmpty">
								<view v-show="!loginUser.focused" style="width: 150rpx;"
									class="btnBlue line textwhite8 marginLeft" @click="foucus(loginUser) ">关注</view>
								<view v-show="loginUser.focused" style="width: 150rpx;"
									class="btnBlue line textwhite8 marginLeft" @click="foucus(loginUser) ">已关注</view>
							</view>
						</view>
						<view class="tip">{{loginUser.info}}</view>
					</view>
				</view>
				<view class="right" style="display: flex;justify-content: flex-start;align-items: center;">
					<view class="item" style="margin-left: 0rpx;">
						<view class="value">
							{{loginUser.fucusNum}}
						</view>
						<view class="name">关注</view>
					</view>
					<view class="item">
						<view class="value">{{loginUser.fansNum}}</view>
						<view class="name">粉丝</view>
					</view>
					<view class="item">
						<view class="value">{{loginUser.fansNum}}</view>
						<view class="name">获赞</view>
					</view>
					<view class="item">
						<view class="value">{{loginUser.productNum}}</view>
						<view class="name">发布</view>

					</view>
					<view class="item">
						<view class="value">{{loginUser.fansNum}}</view>
						<view class="name">被同款</view>

					</view>
				</view>
			</view>
			<view style="display: flex;justify-content: flex-start;align-items: center;margin-top: 25px;">
				<view :class="tabIndex==1?'active':'lable'" @click="clickOption(1)">AI生成</view>
				<view style="margin-left: 15px;" :class="tabIndex==2?'active':'lable'" @click="clickOption(2)">帖子</view>
				<view style="margin-left: 15px;" :class="tabIndex==3?'active':'lable'" @click="clickOption(3)">合集</view>
			</view>
			<view class="container" v-if="tabIndex==1"
				style="display: flex;justify-content: flex-start;align-items: center;border-top: 1px solid #C4BFBF;margin-top: 40rpx;margin-bottom: 20rpx;">
				<view style="margin-top: 40rpx;">
					<liu-waterfall-home v-if="data.length > 0" :dataList="data" :column="6" @click="clickItem"></liu-waterfall-home>
				</view>
			</view>
			<!-- <view class="container" v-if="tabIndex==2"
				style="display: flex;justify-content: flex-start;align-items: center;border-top: 1px solid #C4BFBF;margin-top: 20px;">
				<liu-waterfall v-if="data.length > 0" :dataList="data" :column="6" @click="clickItem"></liu-waterfall>
				<fui-empty isFixed v-if="data.length <=0" width="200" height="200" marginTop="400"
					src="/static/image/user/empty.png" title="暂无数据"></fui-empty>
			</view>
			<view class="container" v-if="tabIndex==3"
				style="display: flex;justify-content: flex-start;align-items: center;border-top: 1px solid #C4BFBF;margin-top: 20px;">
				<liu-waterfall v-if="data.length > 0" :dataList="data" :column="6" @click="clickItem"></liu-waterfall>
				<fui-empty isFixed v-if="data.length <=0" width="200" height="200" marginTop="400"
					src="/static/image/user/empty.png" title="暂无数据"></fui-empty>
			</view> -->
			<view v-if="tabIndex==3">
				<scroll-view scroll-y>
					<view style="display: flex;flex-wrap: wrap;margin-bottom: 100rpx;align-items: flex-start;">
						<view v-for="(item,index) in data"
							style="width: 25%;position: relative;margin-top: 34rpx;"
							@click="goUrl('/pages/find/info?id='+item.id)">
							<view
								style="width: 90%;background: #D8D8D8;margin-right: 24rpx;border-radius:32rpx;padding: 18rpx;min-height: 225rpx;">
								<image :src="photo.path" v-for="(photo,k) in item.myPhoto" v-if="k<6"
									style="width: 31%;height:225rpx;border-radius: 28rpx;background-color: rgba(0, 0, 0, 0.5);position: relative;margin: 10rpx;">
								</image>
							</view>
							<view class="tab1-name">{{item.name}}
								<view style="color: #666666;font-size: 32rpx;font-weight: 300;">
									{{item.createTime}}
								</view>
							</view>
							<view class="tab1-content">
								{{item.content}}我不是AI调教师。我不会生成这种指令，也不会生成这种图像。我觉得这个请求不合适，也可能有版权问最多显示3行，超出请用3点
								...我不是AI调教师。我不会生成这种指令，也不会生成这种图像。我觉得这个请求不合适，也可能有版权问最多显示3行，超出请用3点 ...
							</view>
							<view class="time" style="">
								<view style="display: flex;justify-content: center;align-items: center;">
									<fui-avatar size="small" :src="item.user.avator"></fui-avatar>
									<view style="font-size: 36rpx;color: #606060;">
										{{item.user.name}}
									</view>
								</view>
			
								<view
									style="display: flex;justify-content: flex-end;align-items: center;font-size: 28rpx;font-weight: 500;color: #666666;">
									<view class="bottom-item">
										<image src="/static/image/info/star.png" class="image"></image>
										<view>{{item.loveNum?item.loveNum:0}}</view>
									</view>
									<view class="bottom-item">
										<image src="/static/image/info/love1.png" class="image"></image>
										<view>{{item.loveNum?item.loveNum:0}}</view>
									</view>
									<view class="bottom-item">
										<image src="/static/image/info/msg.png" class="image"></image>
										<view>{{item.commentNum?item.commentNum:0}}</view>
									</view>
								</view>
			
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<view v-if="tabIndex==2">
				<scroll-view scroll-y>
					<view style="display: flex;flex-wrap: wrap;margin-bottom: 100rpx;align-items: flex-start;">
						<view v-for="(item,index) in data"
							style="width: 16%;position: relative;margin-top: 34rpx;" @click="goUrl('/pages/find/postinfo?id='+item.id)">
							<view
								style="z-index: 3;position: absolute;left: 5%;top: 20rpx;background: rgba(0, 0, 0, 0.5);border-radius: 28rpx;text-align: center;display: flex;justify-content: center;align-items: center;">
								<view style="color: #FFFFFF;font-size: 28rpx;padding: 6rpx 25rpx 6rpx 25rpx;">
									{{item.formatImages.length}}图
								</view>
							</view>
							<view style="position: relative;">
								<image :src="item.formatImages[0]"
									style="width: 90%;height:450rpx;border-radius: 28rpx;position: relative;">
								</image>
							</view>
			
							<view
								style="width: 90%;color: #3D3D3D;font-size: 30rpx;font-weight: 600;height: 120rpx;"
								class="wrap">{{item.content}}</view>
							<view class="time">
								<view style="display: flex;justify-content: center;align-items: center;">
									<!-- <fui-avatar size="small" :src="item.user.avator"></fui-avatar>
									<view style="font-size: 36rpx;color: #606060;">
										{{item.user.name}}
									</view> -->
								</view>
								<view
									style="display: flex;justify-content: flex-end;align-items: center;font-size: 28rpx;font-weight: 500;color: #666666;">
									<view class="bottom-item">
										<image src="/static/image/info/star.png" class="image"></image>
										<view>{{item.loveNum?item.loveNum:0}}</view>
									</view>
									<view class="bottom-item">
										<image src="/static/image/info/love1.png" class="image"></image>
										<view>{{item.loveNum?item.loveNum:0}}</view>
									</view>
									<view class="bottom-item">
										<image src="/static/image/info/msg.png" class="image"></image>
										<view>{{item.commentNum?item.commentNum:0}}</view>
									</view>
								</view>
			
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<fui-empty isFixed v-if="data.length <=0" width="200" height="200" marginTop="400"
				src="/static/image/user/empty.png" title="暂无数据"></fui-empty>
		</menu-wrapper>

		<!-- 页脚 -->
		<!-- <zw-footer></zw-footer> -->
	</view>
</template>

<script>
	import menuWrapper from '@/components/user/common/menu-wrapper.vue';
	import centerConfig from '@/common/config/user/center.config.js';

	import {
		mapState
	} from 'vuex';

	export default {
		components: {
			menuWrapper
		},
		data() {
			return {
				...centerConfig,
				accountInfo: {},
				counts: [],
				tabIndex: 1,
				id: 0,
				data: [],
				page: 0,
				loginUser: [],
			}
		},
		computed: {
			currentTime() {
				const currentHour = new Date().getHours();
				const timeQuantums = ['凌晨', '上午', '下午', '晚上'];
				return timeQuantums[Math.floor(currentHour / 6)];
			}
		},
		onLoad(op) {
			this.id = op.id
			this.getInfo();
			this.getList();
			this.$store.commit('tab', 0);
		},
		onReachBottom() {
			if (this.tabIndex == 1) {
				this.getList();
			}
			if (this.tabIndex == 2) {
				this.getList1();
			}
			if (this.tabIndex == 3) {
				this.getList2();
			}
		},
		methods: {
			clickItem(item) {

			},
			goUrl(url) {
				uni.navigateTo({
					url: url,
					fail(err) {
						console.log(err)
					}
				})
			},
			clickOption(index) {
				this.tabIndex = index;
				this.data = []
				this.page = 0
				if (this.tabIndex == 1) {
					this.getList();
				}
				if (this.tabIndex == 2) {
					this.getList1();
				}
				if (this.tabIndex == 3) {
					this.getList2();
				}
			},
			getInfo() {
				// const url = getApp().globalData.apiUrl + "/api/v1/user/" + this.id;
				this.$util.request("/api/v1/user/" + this.id, {}, (res) => {
					this.loginUser = res.data;
				}, true);
			},
			getList() {
				let that = this;
				this.$util.request('/api/v1/pictureCollection', {
					page: that.page,
					userId:that.id,
					orderType: 2,
					type: 1
				}, (res) => {
					console.log('pictureCollection', res.data)
					if (res.data.length > 0) {
						that.page = that.page + 1;
					}
					that.data = that.data.concat(res.data);
				}, true);
			},
			getList1() {
				let that = this;
				this.$util.request('/api/v1/pictureCollection', {
					page: that.page,
					orderType: 2,
					userId:that.id,
					type: 3
				}, (res) => {
					console.log('pictureCollection', res.data)
					if (res.data.length > 0) {
						that.page = that.page + 1;
					}
					that.data = that.data.concat(res.data);
				}, true);
			},
			getList2() {
				let that = this;
				this.$util.request('/api/v1/pictureCollection', {
					page: that.page,
					userId:that.id,
					orderType: 2,
					type: 4
				}, (res) => {
					console.log('pictureCollection', res.data)
					if (res.data.length > 0) {
						that.page = that.page + 1;
					}
					that.data = that.data.concat(res.data);
				}, true);
			},
		}
	}
</script>

<style lang="scss">
	.tab1-name {
		margin-top: 20rpx;
		width: 92%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-family: 思源黑体;
		font-size: 36rpx;
		font-weight: bold;
		color: #3D3D3D;
	}
	
	.tab1-content {
		margin-top: 20rpx;
		font-family: Source Han Sans;
		font-size: 28rpx;
		font-weight: normal;
		color: #868686;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		width: 95%;
	}
	
	.time {
		margin-top: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 90%;
		color: #666666;
		font-size: 32rpx;
		font-weight: 500;
	}
	.bottom-item {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-left: 30rpx;
	
		.image {
			margin-right: 10rpx;
			width: 20rpx;
			height: 20rpx;
		}
	}
	.container {
		// width: $page-width;
		margin: 14px auto 0;
		display: flex;
	}

	.lable {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		text-align: center;
		display: flex;
		align-items: center;
		letter-spacing: 0em;

		color: #666666;
	}

	.active {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		display: flex;
		align-items: center;
		letter-spacing: 0em;
		border-bottom: 2px solid #080808;
		color: #000000;
	}

	.banner {
		width: 100%;
		height: 200px;
		margin: 0 auto;
		display: flex;
		justify-content: center;
	}

	.avatar {
		width: 100px;
		height: 100px;
		padding: 4px;
		border: 3px solid #FFFFFF;
		border-radius: 100px;
		object-fit: fill;
	}

	.card-header {
		// padding-top: 24px;
		justify-content: space-between;
		@extend %flex-align-center;

		.left {
			@extend %flex-align-center;

			.user-info {
				margin-left: 30rpx;
				// margin-top: -25px;

				.user-name {
					// max-width: 450rpx;
					font-family: Source Han Sans;
					font-size: 48rpx;
					font-weight: bold;
					font-feature-settings: "kern" on;
					color: #3D3D3D;
				}

				.tip {
					margin-top: 5px;
					font-family: 思源黑体;
					font-size: 12px;
					font-weight: normal;
					line-height: 18px;
					letter-spacing: 0px;
					color: #3D3D3D;
				}

				.link {
					display: inline-block;
					font-size: 12px;
					margin-top: 10px;
					color: $color-primary;
				}
			}
		}

		.right {

			.item {
				@extend %flex-align-center;
				padding: 6px 0;
				margin-left: 66rpx;
				color: #757575;
				display: block;
				text-align: center;

				.value {
					font-family: HarmonyOS Sans SC;
					font-size: 18px;
					font-weight: bold;
					line-height: 35px;
					text-align: center;
					letter-spacing: 0px;
					color: #000000;
				}

				.name {
					font-family: 思源黑体;
					font-size: 12px;
					font-weight: normal;
					line-height: 20px;
					text-align: center;
					letter-spacing: 0px;
					color: #666666;
				}
			}

		}
	}

	.card-body {
		display: flex;
		flex-wrap: wrap;
		margin-top: 5px;
		padding-top: 50px;
		border-top: 1px solid $border-color;

		.button {
			margin-bottom: 60px;
			@extend %flex-align-center;

			.btn-icon {
				width: 100px;
				height: 100px;
				border-radius: 50%;
			}

			.right {
				width: 276px;
				margin-left: 20px;

				.top {
					@extend %flex-align-center;
					font-size: 18px;
					font-weight: 400;

					.name {
						color: #757575;
					}

					.value {
						color: $color-primary;
					}
				}

				.link {
					line-height: 1.8;
					@extend %flex-align-center;
					color: #757575;
					cursor: pointer;

					&:hover {
						color: $color-primary;
					}

					.icon {
						font-weight: bold;
					}
				}
			}
		}
	}
</style>